package com.yangye.springclouddemozookeeper.listener;

import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author yangye
 * @date 2020/10/19
 */
public class DefaultLoadBanlancer {

	public static List<String> SERVER_LIST = new ArrayList<>();

	public String chooseServiceHost() {
		if (!CollectionUtils.isEmpty(SERVER_LIST)) {
			int i = new Random().nextInt(SERVER_LIST.size());
			return SERVER_LIST.get(i);
		}
		return "";
	}
}
